<template>
  <div>
    <el-cascader
      v-model="value"
      :options="normalizedOptions"
      :placeholder="'请选择'"
      style="width:100%;"
      :props="{multiple:true}"
      popper-class="popper"
      @change="handleChange">
    </el-cascader>
  </div>
</template>

<script lang='ts'>
    import { Component, Prop, Vue } from 'vue-property-decorator';

    @Component
    export default class UserSelector extends Vue {
        @Prop({ type: String })
        readonly targetAccounts! : string;

        value: Array<any>=[];
        normalizedOptions:Array<any>=[];
        async created () {
            console.log(this.targetAccounts)
           let options = new Array(12).fill(1);
           this.normalizedOptions = await options.map((month, index) => ({
               value: index + 1,
               label: (index + 1).toString() + '月'
           }));
           if (this.targetAccounts) {
                this.value = JSON.parse(this.targetAccounts);
            }
        }
        handleChange(value) {
            // console.log(value);
            this.$emit('change', value, 0)
        }
    }
</script>

<style lang="less" scoped>
  /deep/ .popper .el-cascader-panel .el-checkbox{
    padding: 10px 50px;
  }
</style>
